load("//tools/install:install.bzl", "install")
load(
    "//tools/skylark:pybind.bzl",
    "get_drake_py_installs",
    "get_pybind_package_info",
)
load(
    "//tools/skylark:drake_py.bzl",
    "drake_py_binary",
    "drake_py_library",
)
load("//bindings/pydrake:pydrake.bzl", "add_lint_tests_pydrake")

package(default_visibility = [
    "//bindings/pydrake:__subpackages__",
])

# This determines how `PYTHONPATH` is configured, and how to install the
# bindings.
PACKAGE_INFO = get_pybind_package_info("//bindings")

drake_py_library(
    name = "module_py",
    srcs = ["__init__.py"],
    deps = [
        "//bindings/pydrake/examples",
    ],
)

drake_py_library(
    name = "cart_pole_passive_simulation_py",
    srcs = ["cart_pole_passive_simulation.py"],
    data = [
        "//examples/multibody/cart_pole:cart_pole.sdf",
    ],
    deps = [
        ":module_py",
        "//bindings/pydrake:lcm_py",
        "//bindings/pydrake/multibody:parsing_py",
        "//bindings/pydrake/multibody:plant_py",
        "//bindings/pydrake/systems:analysis_py",
        "//bindings/pydrake/visualization",
    ],
)

drake_py_binary(
    name = "cart_pole_passive_simulation",
    srcs = ["cart_pole_passive_simulation.py"],
    add_test_rule = 1,
    test_rule_args = [
        "--target_realtime_rate=0",
        "--simulation_time=0.1",
    ],
    visibility = ["//visibility:public"],
    deps = [
        ":cart_pole_passive_simulation_py",
    ],
)

drake_py_library(
    name = "pendulum_lqr_monte_carlo_analysis_py",
    srcs = ["pendulum_lqr_monte_carlo_analysis.py"],
    data = ["//examples/pendulum:models"],
    deps = [
        ":module_py",
        "//bindings/pydrake/multibody",
        "//bindings/pydrake/systems",
    ],
)

drake_py_binary(
    name = "pendulum_lqr_monte_carlo_analysis",
    srcs = ["pendulum_lqr_monte_carlo_analysis.py"],
    add_test_rule = 1,
    test_rule_args = [
        "--num_samples=10",
        "--torque_limit=2.0",
    ],
    visibility = ["//visibility:public"],
    deps = [
        ":pendulum_lqr_monte_carlo_analysis_py",
    ],
)

drake_py_library(
    name = "run_planar_scenegraph_visualizer_py",
    srcs = ["run_planar_scenegraph_visualizer.py"],
    data = ["//examples/pendulum:models"],
    deps = [
        ":module_py",
        "//bindings/pydrake/examples",
        "//bindings/pydrake/multibody",
        "//bindings/pydrake/systems",
    ],
)

drake_py_binary(
    name = "run_planar_scenegraph_visualizer",
    srcs = ["run_planar_scenegraph_visualizer.py"],
    add_test_rule = 1,
    visibility = ["//visibility:public"],
    deps = [
        ":run_planar_scenegraph_visualizer_py",
    ],
)

PY_LIBRARIES = [
    ":cart_pole_passive_simulation_py",
    ":pendulum_lqr_monte_carlo_analysis_py",
    ":run_planar_scenegraph_visualizer_py",
]

# Package roll-up (for Bazel dependencies).
# N.B. `examples` packages do not have `all` modules.
drake_py_library(
    name = "multibody",
    imports = PACKAGE_INFO.py_imports,
    deps = PY_LIBRARIES,
)

install(
    name = "install",
    targets = PY_LIBRARIES,
    py_dest = PACKAGE_INFO.py_dest,
)

add_lint_tests_pydrake()
